Hi, I am new to dxl. trying many things to compare attributes with previous baselines and showing the differences since many days but no luck. Here is another code I tried. Its the example code given by IBM to create a new column for displaying the changes made. I have contributed my changes with the code. It was designed for comparing and showing the difference between Object Text only. I tried to make it for all the attributes available in current module.
But no luck .
I am using a separate Dialog Box to show the attributes in the current module "AttrShow.dxl" and selecting and passing them to this file "BigDialog.dxl". Attached both the files. Can anyone please help me with this. The problem is that its not showing the resultant diff in the column made.
Any help appreciated.
/*
The original version can be selected from the following sources:
- the current value of Object Text, so that all future changes are marked up in the history column
- the Object Text as it was in a named baseline of the current Module
- the value of a named attribute.
The original text is stored in a text attribute called "Old Text", and
can be over-written by a subsequent use of the tool.
The fonts used to mark up the changes in text can be selected. The
default is to show inserted text using underline, and deleted text
using strike-through.
Current limitations:
- changes to fonts in the object text are ignored.
- deleted and moved objects are not portrayed as changes.
*/
pragma runLim,0
#include <example/include/dbs.inc>
#include <example/include/delta.inc>
#include <example/include/objects.inc>
///////////////////////////////////////////////////////////
// Constants
const int MAXATTRS = 50 // maximum number of text attributes
const int MAXBASES = 50 // maximum number of baselines
const string OLDTEXTATTR = (NLS_("Old Text")) // name of attribute to store old version of attribute
const string HISTORYATTR = (NLS_("Delta Text")) // name of attribute to store history of attribute
const string oldOpts[] = { (NLS_("From current ")), (NLS_("From baseline")), (NLS_("From attribute")) }
// ^^^^^^^^
// padding for layout purposes
const string fontOpts[] = { (NLS_("Bold")), (NLS_("Italic")), (NLS_("Underline")), (NLS_("StrikeThrough")) }
const string creationOpts[] = { (NLS_("DXL column")), (NLS_("DXL attribute")) }
const string helpScript =
(NLS_("This tool creates a DXL column or attribue which uses a rich-text ")) //-
(NLS_("markup scheme to show changes to attribute with respect to some ")) //-
(NLS_("original version.\n\n")) //-
(NLS_("The original version can be selected from the following sources:\n")) //-
(NLS_("\n")) //-
(NLS_(" - the current value of Object attribute, so that all future changes are marked ")) //-
(NLS_("up in the history column\n")) //-
(NLS_("\n")) //-
(NLS_(" - the Object attribute as it was in a named baseline of the current Module\n")) //-
(NLS_("\n")) //-
(NLS_(" - the value of a named attribute.\n")) //-
(NLS_("\n")) //-
(NLS_("The original value of attribute is stored in a text attribute called \"")) OLDTEXTATTR (NLS_("\", and can be ")) //-
(NLS_("over-written by a subsequent use of the tool.\n")) //-
(NLS_("\n")) //-
(NLS_("The fonts used to mark up the changes in text can be selected. ")) //-
(NLS_("The default is to show inserted text using underline, and deleted text using strike-through.\n")) //-
(NLS_("\n")) //-
(NLS_("Current limitations:\n")) //-
(NLS_(" - changes to fonts in the object text are ignored.\n")) //-
//(NLS_(" - changes to attributes other than Object Text are not shown.\n")) //-
(NLS_(" - deleted and moved objects are not portrayed as changes."))
///////////////////////////////////////////////////////////
// Variables
Module currMod = current
Object currObj = current
string dummyList[] = {}
string attrList[MAXATTRS] // list of text attirbutes
string baseList[MAXBASES] // list of baselines
Skip baseSkip = createString // mapping baseline name to baseline
Skip baseObjects = create() // mapping absolute number to baseline object
Skip selectAttr=create()
int ky2=0
///////////////////////////////////////////////////////////
// Dialogs
DB db = null
DBE helpText = null
DBE oldTextOption = null
DBE baseChoice = null
DBE attrChoice = null
DBE newTextFont = null
DBE oldTextFont = null
DBE AttList= null
DBE colAttrChoice = null
DBE insertButton = null
DBE textSizeLimit = null
int TotalAttr=0
///////////////////////////////////////////////////////////
// Auxiliary functions
void fillAttributeList(DBE dbe) {
// scan all attributes
int n = 0
AttrDef ad
for ad in current Module do {
// reject non-object attributes
if ( !ad.object ) continue
// reject attributes that are not text
//if ( ad.typeName != (NLS_("Text")) ) continue
// reject Object Text
if ( ad.name == (NLS_("Object Text")) ) continue
attrList[n++] = ad.name
}
set(dbe, attrList, n)
TotalAttr=n
}
void fillBaselineList(DBE dbe) {
// empty skip list
Baseline b
for b in baseSkip do {
string bn = key baseSkip
delete(baseSkip, bn)
}
// refill skip list and choice list
int n = 0
for b in current Module do {
string baseName = (major b) (NLS_(".")) (minor b) (NLS_(" (")) (suffix b) (NLS_(")"))
baseList[n++] = baseName
put(baseSkip, baseName, b)
}
set(dbe, baseList, n)
}
string getMarkup(int fontNum)
{
//{ "Bold", "Italic", "Underline", "StrikeThrough" }
string result = (NLS_(""))
if (1 == (1 & fontNum)) {
result = (NLS_("\\\\b "))
}
if (2 == (2 & fontNum)) {
result = (NLS_("\\\\i "))
}
if (4 == (4 & fontNum)) {
result = (NLS_("\\\\ul "))
}
if (8 == (8 & fontNum)) {
result = (NLS_("\\\\strike "))
}
return (NLS_("\"")) result (NLS_("\""))
}
///////////////////////////////////////////////////////////
// Call backs
void doCreate(DB db)
{ print"\nin create db"
string s
for s in selectAttr do{
AttrDef ad1= find(currMod, s)
AttrType typ = ad1.type
// create attribute for saving old version
if ( !exists attribute OLDTEXTATTR ) {
//create object type (NLS_(stringOf(at.type))) history false changeBars false attribute OLDTEXTATTR
create object type ((typ.name)) history false changeBars false attribute OLDTEXTATTR
}
print"\nA1\nAttribute type is \n"
print ad1.typeName
//print s
print "\nD "
// set old attribute values
int opt = get oldTextOption
int attr = get attrChoice
int base = get baseChoice
int colAttr = get colAttrChoice
string txtLim = get textSizeLimit
string attrName = ( attr >= 0 ? attrList[attr] : (NLS_("")) )
string baseName = ( base >= 0 ? baseList[base] : (NLS_("")) )
string baselineText = (NLS_(""))
Baseline baseLine = null
Module baseMod = null
if ( opt == 2 ) {
// check values
if ( attrName == (NLS_("")) ) {
ack (NLS_("No attribute named."))
return
}
}
if ( opt == 1 ) {
// check values
if ( baseName == (NLS_("")) ) {
ack (NLS_("No baseline named."))
return
}
// for baseline choice, open baseline module and build index to objects
// get baseline info
baselineText = (NLS_(" ")) baseName
if ( !find(baseSkip, baseName, base) ) {
ack (NLS_("Cannot access baseline ")) baseName
return
}
// open baseline module
if ( !find(baseSkip, baseName, baseLine) ) {
ack (NLS_("Failed to load baseline module ")) baseName
return
}
baseMod = load(currMod, baseLine, false)
// build index
Object o
for o in baseMod do {
int ky = intOf (o.(NLS_("Absolute Number")) (NLS_("")))
put(baseObjects, ky, o)
}
}
Object o
for o in currMod do {
if ( !lockObj o ) continue
string oldVal = (NLS_(""))
if ( opt == 0 ) {
// use current value of object text
oldVal = o.(NLS_(s))
print "\nE1"
} else if ( opt == 1 ) {
// use value of object text from named baseline
int absNum = intOf(o.(NLS_("Absolute Number")) (NLS_("")))
Object b
if ( find(baseObjects, absNum, b) ) {
oldVal = b.(NLS_(s))
print "\nE2"
} else {
oldVal = (NLS_(""))
}
} else if ( opt == 2 ) {
// use value of named attribute
oldVal = o.attrName
}
o.OLDTEXTATTR = oldVal
if ( o.(NLS_(s)) (NLS_("")) != oldVal ) accept o
else reject o
}
// get font settings
int oldFont = get oldTextFont
int newFont = get newTextFont
string removeMarkup = getMarkup(oldFont)
string insertMarkup = getMarkup(newFont)
if ( colAttr == 1 ) {
print "\nE4"
// create attribute
AttrDef ad = find(currMod, HISTORYATTR)
if ( !null ad ) {
if ( confirm ((typ.name)) HISTORYATTR (NLS_("' already exists.\n\nOverwrite?")) ) {
delete(currMod, ad)
} else {
return
}
}
print "\nE3"
string code = (NLS_("pragma runLim,0\n")) //-
(NLS_("Buffer o = create()\n")) //-
(NLS_("o = obj.\"")) OLDTEXTATTR (NLS_("\"\n")) //-
(NLS_("Buffer n = create()\n")) //-
(NLS_("n = obj.\"\"\n")) //-
(NLS_("if ( length(o) > ")) txtLim (NLS_(" || length(n) > ")) txtLim (NLS_(" ) \n")) //-
(NLS_("{\n")) //-
(NLS_(" obj.s\"\n")) HISTORYATTR (NLS_("\" = richText \"{\\\\i (Text too big to compare.)}\"\n")) //-
(NLS_("} else\n")) //-
(NLS_("{\n")) //-
(NLS_(" Buffer resBuf = create\n")) //-
(NLS_(" diff(resBuf, o, n, ")) removeMarkup (NLS_(", ")) insertMarkup (NLS_(")\n")) //-
(NLS_(" obj.\"")) HISTORYATTR (NLS_("\" = richText resBuf\n")) //-
(NLS_(" print resbuf "))//-
(NLS_(" delete resBuf\n")) //-
(NLS_("}\n")) //-
(NLS_("delete(o)\n")) //-
(NLS_("delete(n)\n"))
current = currMod
print "\nB "
//print stringOf at
// AttrType typ1 = ad.type
print "attribute typr finally"
print typ.name
create object type (NLS_(typ.name)) attribute HISTORYATTR
print "attribute typr finally"
print typ.name
ad = find(currMod, HISTORYATTR)
print "\nA "
if ( null ad ) {
ack (NLS_("Could not create attribute."))
return
}
}
// create column
string code = (NLS_("pragma runLim,0\n")) //-
(NLS_("Buffer o = create()\n")) //-
(NLS_("o = obj.\"")) OLDTEXTATTR (NLS_("\"\n")) //-
(NLS_("Buffer n = create()\n")) //-
(NLS_("n = obj.s\"\n")) //-
(NLS_("if ( length(o) > ")) txtLim (NLS_(" || length(n) > ")) txtLim (NLS_(" ) \n")) //-
(NLS_("{\n")) //-
(NLS_(" displayRich \"{\\\\i (Text too big to compare.)}\"\n")) //-
(NLS_("} else\n")) //-
(NLS_("{\n")) //-
(NLS_(" Buffer resBuf = create\n")) //-
(NLS_(" diff(resBuf, o, n, ")) removeMarkup (NLS_(", ")) insertMarkup (NLS_(")\n")) //-
(NLS_(" displayRich (tempStringOf resBuf)\n")) //-
(NLS_(" print resbuf "))//-
(NLS_(" delete resBuf\n")) //-
(NLS_("}\n")) //-
(NLS_("delete(o)\n")) //-
(NLS_("delete(n)\n"))
current = currMod
insert column 2
title(column 2, (NLS_("Changed/Deleted Text for ")s) baselineText)
width(column 2, 300)
justify(column 2, full)
if ( colAttr == 0 ) {
dxl(column 2, code)
print "F1 "
} else {
attribute(column 2, HISTORYATTR)
print "\nF2 "
}
refresh current
}
hide db
}
void doSelectOption(DBE dbe) {
int opt = get oldTextOption
if ( opt == 2 ) {
active attrChoice
inactive baseChoice
fillAttributeList attrChoice
//fillAttributeList AttList
} else if ( opt == 1 ) {
active baseChoice
inactive attrChoice
fillBaselineList baseChoice
} else {
inactive attrChoice
inactive baseChoice
}
}
void doClose(DB db) {
hide db
}
///////////////////////////////////////////////////////////
// Main program
void ShowBigDialog(Skip attrSelected ){
print "we are in Big Dialog option"
string s
for s in attrSelected do{
put(selectAttr,ky2++,s)
print s
}
db = create ((NLS_("Insert Changes column")), styleThemed|styleAutoparent)
label(db, (NLS_("Instructions:")))
helpText = text(db, (NLS_("")), helpScript, 200, 200, true)
separator db
oldTextOption = verticalRadioBox(db, (NLS_("Source of original version:")), oldOpts, 0)
beside db
label(db, (NLS_(" "))) // horizontal padding
label(db, (NLS_(" "))) // horizontal positioning
below db
label(db, (NLS_(" "))) // vertical padding
baseChoice = choice(db, (NLS_("Baseline:")), dummyList, 0, 0)
attrChoice = choice(db, (NLS_("Attribute:")), dummyList, 0, 0)
//AttList= multiList(db,(NLS_("Attribute:")),5,attrList,TotalAttr)
left db
separator db
label(db, (NLS_("Fonts to use for marking text:")))
newTextFont = checkBox(db, (NLS_("Inserted text:")), fontOpts, 5)
oldTextFont = checkBox(db, (NLS_("Deleted text:")), fontOpts, 9)
colAttrChoice = radioBox(db, (NLS_("Create:")), creationOpts, 1)
textSizeLimit = field(db, (NLS_("Maximum size of text to compare:")), (NLS_("10000")), 10)
insertButton = apply(db, (NLS_("Create")), doCreate)
closeWithTrigger(db, true, doClose)
set(oldTextOption, doSelectOption)
doSelectOption null
show db
}
Sadaf - Fri Apr 10 18:48:06 EDT 2015 |